package corej.course.net;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.Socket;

public class TCPClient {

    public static void main(String[] args) throws Exception {
        //1.创建Socket，包括ip及端口号
        Socket s = new Socket("127.0.0.1", 9000);

        //2.得到socket的输入流
        InputStream is = s.getInputStream();

        //3.封装并打印
        InputStreamReader ir = new InputStreamReader(is);
        BufferedReader in = new BufferedReader(ir);
        for (int i = 1; i <= 20; i++) {
            System.out.println(in.readLine());
        }
        s.close();
    }

}
